#! /usr/bin/python

def init(data):
    data['first'] = {}
    data['middle'] = {}
    data['last'] = {}

def lookup(data, label, name):
    return data[label].get(name)

# Add variable parameter
def store(data, *full_names):
    for full_name in full_names:
        names = full_name.split()
        if len(names) == 2:
            names.insert(1, '')
        labels = 'first', 'middle', 'last'
        for label, name in zip(labels, names):
            people = lookup(data, label, name)
            if people:
                people.append(full_name)
            else:
                data[label][name] = [full_name]

def main():
    myName = {}
    init(myName)
    store(myName, 'Andy Li')
    store(myName, 'Ruby Liu')
    store(myName, 'Luke Skywalker', 'Anakin Liu')
    print myName
    print lookup(myName, 'first', 'Andy')
    print lookup(myName, 'last', 'Liu')
    print lookup(myName, 'first', 'Luke')

if __name__ == '__main__':
    main()



